﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class UIOnEnter : MonoBehaviour 
{
	[System.Serializable] public struct ExceptionField
	{
		public Selectable selectable;
		public Button button;
	}
	public ExceptionField[] exception;
	public Button standardButton;
	public EventSystem eventSystem;

	void Update()
	{
		if (Input.GetButtonDown ("Submit"))
		{	
			if (exception != null)
			{
				foreach (ExceptionField thisException in exception)
				{	
					if (eventSystem.currentSelectedGameObject == thisException.selectable.gameObject)
					{	
						Debug.Log (thisException.button.name);
						thisException.button.onClick.Invoke();
						return;
					}
				}
			}
			standardButton.onClick.Invoke();
		}
	}
}
